package com.mf.ergate.web.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * 验证码配置类
 * User: liuguojian
 * DateTime: 2018-05-29
 * To change this template use File | Settings | File Templates.
 */
@Configuration
public class CaptchaConfig {

	@Bean
	public DefaultKaptcha defaultKaptcha() {
		DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
		Properties properties = new Properties();
		properties.setProperty("kaptcha.border", "yes");
		properties.setProperty("kaptcha.border.color", "181,181,181");
		properties.setProperty("kaptcha.textproducer.font.color", "68,143,185");
		properties.setProperty("kaptcha.textproducer.font.size", "35");
		properties.setProperty("kaptcha.textproducer.char.space", "4");
		properties.setProperty("kaptcha.textproducer.char.length", "4");
		properties.setProperty("kaptcha.textproducer.char.string", "1234567890");
		properties.setProperty("kaptcha.textproducer.font.names", "Arial");
		properties.setProperty("kaptcha.image.width", "125");
		properties.setProperty("kaptcha.image.height", "45");
		properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
		Config config = new Config(properties);
		defaultKaptcha.setConfig(config);
		return defaultKaptcha;
	}
}
